import java.util.ArrayList;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Stack;

public class Test {
    public static void main(String[] args) {
        /*LinkedList <Integer> list = new LinkedList <>();
        ArrayList <Integer> list1 = new ArrayList<>();
        Stack <Integer> stack = new Stack<>();
        list1.add(1);*/
    }
}

//逆波兰表达式求值
class Solution {
    public int evalRPN(String[] tokens) {
        Stack <Integer> stack = new Stack<>();
        for(String x : tokens){
            if (isnum(x)) {
                stack.push(Integer.parseInt(x));}
            else {
                int num2 = stack.pop();
                int num1 = stack.pop();
                switch (x){
                    case "+":
                        stack.push(num1+num2);
                        break;
                    case "-":
                        stack.push(num1-num2);
                        break;
                    case "*":
                        stack.push(num1*num2);
                        break;
                    case "/":
                        stack.push(num1/num2);
                        break;
                }
            }

        }
        return stack.pop();
    }
    private Boolean isnum (String a){
        if (a.equals("+") || a.equals("-") ||a.equals("*") || a.equals("/") ) {
            return  false;
        }
        return true;
    }
}